package com.itlong.cloud.smartcard.resource;

import com.itlong.cloud.POJO.DTO.smartcard.SmartCardOldAuthDoorDTO;
import com.itlong.cloud.POJO.DTO.smartcard.SmartCardOldAuthFloorDTO;
import com.itlong.cloud.POJO.DTO.smartcard.SmartCardOldUserInfoDTO;
import com.itlong.cloud.POJO.VO.smartcard.SmartCardOldLoginVO;
import com.itlong.cloud.POJO.VO.smartcard.SmartCardOldUserInfoVO;
import com.itlong.cloud.smartcard.service.ISmartCardOldUserInfoService;
import com.itlong.cloud.user.smartcard.ISmartCardOldUserInfoServiceClient;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <desc>
 *      旧一卡通_用户模块暴露接口实现类。
 * <desc/>
 *
 * @createDate 2017/11/2.
 */
@RestController
public class SmartCardOldUserInfoServiceResource implements ISmartCardOldUserInfoServiceClient {


    private static final Logger LOG = LoggerFactory.getLogger(SmartCardOldUserInfoServiceResource.class);

    @Autowired
    ISmartCardOldUserInfoService iSmartCardOldUserInfoService;

     /**
      * <desc>
      *      获取单个用户所有信息列表。
      * <desc/>
      *
      * @param  phoneNO 手机号码
      * @return
      * @author shengen.T
      * @createDate 2017/11/2
      */
    @Override
    @RequestMapping(path = "/sys/user/manage/list")
    public List<SmartCardOldUserInfoVO> getUserInfoList(@RequestParam("phoneNO") String phoneNO) throws Exception{
       return iSmartCardOldUserInfoService.getUserInfoList(phoneNO);
    }

     /**
      * <desc>
      *      旧一卡通登录。
      * <desc/>
      *
      * @param  account 当前登录账户
      * @return pswd 密码
      * @author shengen.T
      * @createDate 2017/11/2
      */
    @Override
    @RequestMapping(path = "/sys/user/manage/login")
    public SmartCardOldLoginVO login(@RequestParam("account") String account, @RequestParam("pswd") String pswd) throws Exception{
       return iSmartCardOldUserInfoService.login(account,pswd);
    }


    /**
     * <desc>
     *      一卡通检测手机号码是否存在。
     * <desc/>
     *
     * @param  phoneNo 手机号码
     * @return true 存在 false 不存在
     * @author shengen.T
     * @createDate 2017/11/3
     */
    @Override
    @RequestMapping(path = "/sys/user/manage/phone")
    public boolean checkPhone(@RequestParam("phoneNo") String phoneNo) throws Exception{
      return iSmartCardOldUserInfoService.checkPhone(phoneNo);
    }

    /**
     * <desc>
     *      旧一卡通_修改用户。
     * <desc/>
     *
     * @param updateDTO 更新数据
     * @return 返回影响行数
     * @author shengen.T
     * @createDate 2017/11/3
     */
    @Override
    @RequestMapping(path = "/sys/user/manage/update")
    public Integer update(@RequestBody SmartCardOldUserInfoDTO updateDTO) throws Exception{
        return iSmartCardOldUserInfoService.update(updateDTO);
    }

    /**
     * <desc>
     * 旧一卡通_授权门禁
     * <desc/>
     *
     * @param authDoorDTO 门禁权限
     * @return
     * @author Chunjian.G
     * @createDate 2017-12-09
     */
    @Override
    @RequestMapping(path = "/sys/user/manage/authDoor")
    public Integer authDoor(@RequestBody SmartCardOldAuthDoorDTO authDoorDTO,
                             @RequestParam("isSmartCommunity") Integer isSmartCommunity) throws Exception {
        return iSmartCardOldUserInfoService.authDoor(authDoorDTO, isSmartCommunity);
    }

    /**
     * <desc>
     * 旧一卡通_授权电梯
     * <desc/>
     *
     * @param authFloorDTO 电梯权限
     * @return
     * @author Chunjian.G
     * @createDate 2017-12-09
     */
    @Override
    @RequestMapping(path = "/sys/user/manage/authFloor")
    public Integer authFloor(@RequestBody SmartCardOldAuthFloorDTO authFloorDTO,
                              @RequestParam("isSmartCommunity") Integer isSmartCommunity) throws Exception {
        return iSmartCardOldUserInfoService.authFloor(authFloorDTO, isSmartCommunity);
    }


    /**
     * <desc>
     *      获取缓存中的账户信息。
     * <desc/>
     *
     * @param  token
     * @return 返回账户信息
     * @author shengen.T
     * @createDate 2017/11/17
     */
    @Override
    @RequestMapping(path = "/smartCard/getToken")
    public SmartCardOldLoginVO retrieve(@RequestParam("token") String token) throws Exception{
        return iSmartCardOldUserInfoService.retrieve(token);
    }



}
